package com.seari.controller;

import com.seari.annotation.AppCacheName;
import com.seari.bean.AllFullLoadBean;
import com.seari.bean.CYMaxFullLoadBean;
import com.seari.pojo.MessageBean;
import com.seari.service.FullLoadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @ClassName FullLoadController
 * @Description 满载率
 * @Author zhangYanKun
 * @Date 2021/4/29 10:54
 * @Version 1.0
 */
@RestController
@RequestMapping("fullLoad")
public class FullLoadController {

    @Autowired
    private FullLoadService service;

    /**
     * @apiGroup 满载率
     * @api {POST} /fullLoad/avgAndMax4Line 最高区间满载率
     * @apiDescription 满载率前十的线路、区间名、最高满载率和平均满载率
     * @apiSuccessExample 成功响应示例
     * HTTP/1.1 200
     * {
     *      sectionName: '最高满载率区间',
     *      avgSaturation: '平均满载率',
     *      maxSaturation: '最高满载率',
     *      lineName: '线路名称'
     * }
     * @apiVersion 0.0.1
     */
    @RequestMapping("avgAndMax4Line")
    @AppCacheName("cyMaxFullLoad")
    public MessageBean avgAndMaxFullLoad4Line(HttpServletRequest request){
        MessageBean result = new MessageBean();
        List<CYMaxFullLoadBean> data = service.avgAndMaxFullLoad4Line();
        result.setData(data);
        result.setTotal(data.size());
        result.setCode("200");
        return result;
    }

    /**
     * @apiGroup 满载率
     * @api {POST} /fullLoad/allGroupFullLoad 全网所有区间满载率
     * @apiDescription  全网所有区间满载率
     * @apiSuccessExample 成功响应示例
     * HTTP/1.1 200
     * {
     *      "fstrCellsectid": "CELL1354",  区间id
     *      "fstrStartPlatformid": "1333", 起始站点id
     *      "fstrEndPlatformid": "1332",  结束站点id
     *      "fstrCellnameCn": "自然博物馆==>汉中路",   区间名称
     *      "ffltSaturation": 0.12,   满载率
     *      "fdtTime": "2021-05-16 14:27:35.0", 满载率数据获取时间
     *      "frontLineSize": 20   线路粗细
     *      "level": 2,  满载率等级
     * }
     * @apiVersion 0.0.1
     */
    @RequestMapping("allGroupFullLoad")
    @AppCacheName("allGroupFullLoad")
    public MessageBean allGroupFullLoad(HttpServletRequest request){
        MessageBean result = new MessageBean();
        List<AllFullLoadBean> data = service.allGroupFullLoad();
        result.setData(data);
        result.setCode("200");
        return result;
    }
}
